/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.pojo;

import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

/**
 *
 * @author LeMinh
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Product", propOrder = {
    "type",
    "name",
    "price",
    "imgLink",
    "productLink"
})
public class Product implements Serializable {

//    @XmlAttribute(required = true)
//    protected String CateID;
//
//    public void setCateID(String CateID) {
//        this.CateID = CateID;
//    }
//
//    public String getCateID() {
//        return CateID;
//    }
    @XmlElement(required = true)
    protected String type;
    @XmlElement(required = true)
    protected String name;
    @XmlElement(required = true)
    protected String price;
    @XmlElement(required = true)
    protected String imgLink;
    @XmlElement(required = true)
    protected String productLink;

    public Product() {
    }

    public Product(String type, String name, String price, String imgLink, String productLink, String webPage) {
        //this.CateID = id;
        this.type = type;
        this.name = name;
        this.price = price;
        if (!imgLink.contains("http")) {
            this.imgLink = webPage + imgLink;
        } else {
            this.imgLink = imgLink;
        }
        if (!productLink.contains("http")) {
            this.productLink = webPage + productLink;
        } else {
            this.productLink = productLink;
        }
    }

    public String getImgLink() {

        return imgLink;
    }

    public String getName() {
        return name;
    }

    public String getPrice() {
        return price;
    }

    public String getProductLink() {
        return productLink;
    }

    public void setImgLink(String imgLink) {
        this.imgLink = imgLink;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public void setProductLink(String productLink) {
        this.productLink = productLink;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return String.format("Product Name: %s\nPrice: %s\n ImgLink: %s\n Product Link: %s",
                name, price, imgLink, productLink);
    }
}
